<%@ page contentType="text/html; charset=UTF-8" import="com.pub.database.QueryBean,com.pub.web.*"%>
<%
(new WebFunction()).setPortal_to_session(request);
QueryBean qbnDAO=null;
%>
<html>
<%
  String lstrOnloadScript=null;
  String lstrFileName = null;
  try{
    qbnDAO=new QueryBean(request.getParameter("db_alias"),true,"BIG5","BIG5");
    lstrFileName=qbnDAO.readSingleValueData("select file_name from " + request.getParameter("table") + " where flow_code='" + request.getParameter("flow_code") + "' and file_id='" + request.getParameter("file_id") + "'");
    qbnDAO.executeSQL("delete from " + request.getParameter("table") + " where flow_code='" + request.getParameter("flow_code") + "' and file_id='" + request.getParameter("file_id") + "'");
    qbnDAO.executeSQL("insert into attach_log(flow_code,file_id,empno,action,file_name) values('" + request.getParameter("flow_code") + "','" + request.getParameter("file_id") + "','" + request.getSession().getAttribute("u_id").toString() + "','delete','" + lstrFileName + "')");
    lstrOnloadScript="window.close()";
  }
  catch(Exception e){
    lstrOnloadScript="alert('Program error please contact IT!!');window.close();";
    e.printStackTrace();
  }
  finally{
    try{qbnDAO.close();}catch(Exception e){System.out.println("cant close queryBean in DeleteFile.jsp==>" + e.toString());}
    qbnDAO=null;
  }
%>
<body bgcolor="#ffffff" onload="<%=lstrOnloadScript%>">
</body>
</html>
